home *** CD-ROM | disk | FTP | other *** search
- Path: altair.herts.ac.uk!cs4bb
- From: 'Pink Budgie' <cs4bb@herts.ac.uk>
- Newsgroups: comp.lang.c
- Subject: Huge pointer with farcalloc()
- Date: Fri, 29 Mar 1996 10:11:55 +0000
- Organization: University of Hertfordshire
- Message-ID: <Pine.SUN.3.91.960329095306.3773A-100000@altair.herts.ac.uk>
- NNTP-Posting-Host: altair.herts.ac.uk
- Mime-Version: 1.0
- Content-Type: TEXT/PLAIN; charset=US-ASCII
-
- I'm having problems allocating a large (well huge) pointer array for an
- image buffer (800Kb+) using huge pointers and farcalloc under Borland C(++)
- v4.02.
-
- farcalloc returns a void far * which means (I assume) I can create a huge
- pointer and point it at my far buffer thus:
-
- BYTE far *farptr;
- BYTE huge *hugeptr;
-
- farptr = (BYTE far *)farcalloc((unsigned long)5, (unsigned long)100,000);
- hugeptr = (BYTE huge *)farptr;
-
-
- I actually got this to work if I did it exactly like this. But
- the problem I am having is when I try and add a second far pointer to
- point to a smaller farmalloc like this (added to the above):
-
- BYTE far *anotherfarptr;
-
- anotherfarptr = (BYTE far *)farmalloc(2048);
-
-
- Then I need to transfer the contents of *anotherfarptr (a single image
- scanline) to *hugeptr (pointing to the complete image) like this:
-
- for (x = 0; x < xSize; x++) {
- *hugeptr++ = anotherfarptr[2];
- *hugeptr++ = anotherfarptr[1];
- *hugeptr++ = anotherfarptr[0];
- anotherfarptr+=3;
- }
-
- ....and so it goes on.
-
- This is necessary as I am converting PCX to BMP so the scanlines are inverted
- laterally. Whenever I do it this way my *hugeptr becomes a far pointer
- (and thus my whole image buffer is garbled when the end of the segment is
- reached).
-
- Can anyone suggest how to bypass this? I imagine I am not using the
- correct method for using huge pointers, but the documentation is vague.
-
- Please could any answers be copied to my email (M.G.Ross@herts.ac.uk) as
- I don't often get onto these groups. Thanks for any help.
-
- Matt Ross
-